using Test.WebApi.SQLite;
using xu.TinyDBConfigProvider;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();

builder.Host.ConfigureAppConfiguration((hostCtx, configBuilder) =>
{
    string connStr = builder.Configuration.GetConnectionString("DefaultConnection");
    configBuilder.AddTinyDBConfiguration(() => new Microsoft.Data.Sqlite.SqliteConnection(connStr), reloadOnChange: true, reloadInterval: TimeSpan.FromSeconds(2));
});

builder.Services.Configure<LogConfig>(builder.Configuration.GetSection("log"));

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.Run();